package cn.uexpo.lhz.biz.impl;

import cn.uexpo.lhz.biz.StaffImportErrorBiz;
import cn.uexpo.lhz.common.oldBase.BOException;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.oldUtils.PageUtils;
import cn.uexpo.lhz.dao.StaffImportErrorMapper;
import cn.uexpo.lhz.domain.Cameranotiy;
import cn.uexpo.lhz.domain.CameranotiyExample;
import cn.uexpo.lhz.domain.StaffImportError;
import cn.uexpo.lhz.domain.StaffImportErrorExample;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StaffImportErrorBizImpl implements StaffImportErrorBiz {

	@Autowired
	private StaffImportErrorMapper staffErrorMapper;

	@Override
	public int insert(StaffImportError record) throws BOException {
		return staffErrorMapper.insert(record);
	}

	@Override
	public int insertSelective(StaffImportError record) throws BOException {
		return staffErrorMapper.insertSelective(record);
	}

	@Override
	public int deleteByPrimaryKey(Integer id) throws BOException {
		return staffErrorMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int deleteEntity(StaffImportError record) throws BOException {
		return staffErrorMapper.deleteByPrimaryKey(record.getStaffId());
	}

	@Override
	public int deleteByIds(List<Integer> ids) throws BOException {
		for (Integer id : ids) {
			staffErrorMapper.deleteByPrimaryKey(id);
		}
		return 1;
	}

	@Override
	public int delete(List<StaffImportError> records) throws BOException {
		for (StaffImportError record : records) {
			staffErrorMapper.deleteByPrimaryKey(record.getStaffId());
		}
		return 1;
	}

	@Override
	public int deleteByExample(StaffImportErrorExample example) throws BOException {
		return staffErrorMapper.deleteByExample(example);
	}

	@Override
	public int updateByPrimaryKey(StaffImportError record) throws BOException {
		return staffErrorMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKeySelective(StaffImportError record) throws BOException {
		return staffErrorMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByExampleSelective(StaffImportError record, StaffImportErrorExample example) throws BOException {
		return staffErrorMapper.updateByExampleSelective(record,example);
	}

	@Override
	public int updateByExample(StaffImportError record, StaffImportErrorExample example) throws BOException {
		return staffErrorMapper.updateByExample(record,example);
	}

	@Override
	public StaffImportError selectByPrimaryKey(Integer id) throws BOException {
		return staffErrorMapper.selectByPrimaryKey(id);
	}

	@Override
	public StaffImportError selectByUniqueCode(String uniqueCode) throws BOException {
		StaffImportError item=null;
		StaffImportErrorExample example=new StaffImportErrorExample();
		StaffImportErrorExample.Criteria citeria=example.createCriteria();
		citeria.andUntitled2EqualTo(uniqueCode);
		List<StaffImportError> items=staffErrorMapper.selectByExample(example);
		if (items!=null&&items.size()>0) {
			item=items.get(0);
		}
		return item;
	}

	@Override
	public List<StaffImportError> selectByExample(StaffImportErrorExample example) throws BOException {
		return staffErrorMapper.selectByExample(example);
	}

	@Override
	public long countByExample(StaffImportErrorExample example) throws BOException {
		return staffErrorMapper.countByExample(example);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest, StaffImportErrorExample example) throws BOException {
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
		PageHelper.startPage(pageNum, pageSize);
//	    List<StaffImportError> records = (List<StaffImportError>) staffErrorMapper.selectByExampleWithBLOBs(example);//初始化查看图片
		List<StaffImportError> records = (List<StaffImportError>) staffErrorMapper.selectByExample(example);//初始化不查看图片
		return PageUtils.getPageResult(pageRequest, new PageInfo<StaffImportError>(records));
	}

	@Override
	public List<StaffImportError> selectByExampleWithBLOBs(StaffImportErrorExample example) throws BOException {
		return staffErrorMapper.selectByExampleWithBLOBs(example);
	}

	@Override
	public int updateByExampleWithBLOBs(StaffImportError record, StaffImportErrorExample example) throws BOException {
		return 0;
	}

	@Override
	public int updateByPrimaryKeyWithBLOBs(StaffImportError record) throws BOException {
		return staffErrorMapper.updateByPrimaryKeyWithBLOBs(record);
	}
}
